package com.liangwj.springbootdesignpatterns.createTypePatterns.simpleFactoryPattern;
/**
 * <b>Description:</b> 工厂类 <br/>
 * @author Lingwenjun
 * @date 2019/1/21-10:52
 * @version 1.0
 */
public class SendFactory {

    /**
     * 简单工厂模式-普通
     */
    public Sender produce(String type) {
        if ("mail".equals(type)) {
            return new MailSender();
        } else if ("sms".equals(type)) {
            return new SmsSender();
        } else {
            System.out.println(" type error");
            return null;
        }
    }

    /**
     * 简单工厂模式--多方法
     */
    public Sender produceMail() {
        return new MailSender();
    }

    public Sender produceSms() {
        return new SmsSender();
    }

    /**
     * 简单工厂模式-- 多个静态方法
     */
    public static Sender produceStaticMail() {
        return new MailSender();
    }

    public static Sender produceStaticSms() {
        return new SmsSender();
    }
}
